# pip  install selenium
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
# driver = webdriver.Chrome()
sleep(2)
driver.get("http://www.baidu.com")
# driver.get("https://home.firefoxchina.cn/")
sleep(2)
# driver.quit()
#ID
# driver.find_element(By.ID,"kw").send_keys("哪吒")
#NAME
# driver.find_element(By.NAME,"wd").send_keys("太白金星")
#CLASS_NAME
# driver.find_element(By.CLASS_NAME,"s_ipt").send_keys("太白金星")
# driver.find_element(By.NAME,"key").send_keys("太白金星")
#TAG_NAME
# driver.find_element(By.TAG_NAME,"input").send_keys("哪吒")
#link_text
# driver.find_element(By.LINK_TEXT,"新闻").click()
#part_link
# driver.find_element(By.PARTIAL_LINK_TEXT,"新").click()
#xpath
# driver.find_element(By.XPATH,'/html/body/div[1]/div[1]/div[3]/a[1]')
# """
# //* 任意元素[@id="kw"]相对路径
#/html/body/div[1]/div[1]/div[3]/a[1]绝对路径
# """
#css选择器 selector
# driver.find_element(By.CSS_SELECTOR,'#kw').send_keys("周慧敏")
# sleep(2)
# 清除
# driver.find_element(By.ID,"kw").clear()
# sleep(2)
# 点击 submit(只能点按钮)click()
# # driver.find_element(By.CSS_SELECTOR,"#su").submit()
# sleep(2)
#size尺寸
print(driver.find_element(By.CSS_SELECTOR,"#su").size)
#text属性
aa=driver.find_element(By.LINK_TEXT,"新闻").text
print(aa)
#get_attribute()获取属性值
aa=driver.find_element(By.ID,"su").get_attribute("value")
print(aa)
aa=driver.find_element(By.ID,"su").text
print(aa)
driver.quit()